<template>
  <section>
    <van-cell-group>
      <van-cell title="系统设置" is-link :to="{name: 'SiteConfig'}" />
    </van-cell-group>

    <van-cell-group class="mt10">
      <van-cell title="广告位" is-link :to="{name: 'AdvPosition'}" />
      <van-cell title="广告" is-link :to="{name: 'AdvLists'}" />
    </van-cell-group>

    <van-cell-group class="mt10">
      <van-cell title="管理员" is-link :to="{name: 'AdminLists'}" />
      <van-cell title="角色" is-link :to="{name: 'RoleLists'}" />
      <van-cell title="资源" is-link :to="{name: 'ResourceLists'}" />
    </van-cell-group>

    <van-cell-group class="mt10">
      <van-cell title="修改密码" is-link :to="{name: 'AdminPassword'}" />
      <van-cell title="退出登录" is-link @click="logout" />
    </van-cell-group>

    <Tabbar active="setting" />
  </section>
</template>

<script>
  import Vue from 'vue';
  import {Cell, CellGroup, Toast} from 'vant';
  import Tabbar from '../componets/Tabbar';
  import {userLogoutUri} from "../../common/api";
  Vue.use(Cell).use(CellGroup).use(Toast);

  export default {
    components: {
      Tabbar: Tabbar
    },
    data() {
      return {}
    },
    methods: {
      logout() {
        const that = this;
        const url = userLogoutUri;
        this.$http.get(url).then(response => {
          let {code, msg, data} = response.body
          if (code != 0) {
            Toast.fail(msg);
          } else {
            window.localStorage.removeItem('access_token');
            that.GLOBAL.userInfo = null;
            that.$router.push({name: 'UserLogin'});
          }
        }, response => {
          // error callback
        })
      }
    },
    mounted: function () {

    }
  }
</script>

<style scoped>

</style>
